<?php

namespace app\order\logic;

use app\common\library\RedissLock;
use app\common\service\JinyiApiService;
use app\common\service\ShunfengApiService;
use app\common\service\YiJTApiService;
use think\facade\Db;
use think\facade\Cache;

class OrderShipServiceLogic
{
    /**
     * 订单发货队列消费
     * @param $data
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function orderShippingQueueConsume($data)
    {

        htmlLog(['data'=>$data],OPERATE_LOG . date('Ym') . '/orderShippingQueueConsume/' . date('Ymd') . '.txt');



        if(!$data['warehouse_id'] || !$data['order_id'])  return  true;
            $log =[];
            $log['code']         = 1;
            $log['order_id']     = $data['order_id'];
            $log['shop_id']      = $data['shop_id'];
            $log['time']         = time();
            $log['warehouse_id'] = $data['warehouse_id'];
            OrderShipLogic::insertOrderShipLog($log);

         /*   if ($data['warehouse_id'] == 3){
                $jinyiApi    = new JinyiApiService();
                $jinyiApi->createOrder($data);
            }*/

            if ($data['warehouse_id'] == 4){
                $shunfengApi = new ShunfengApiService();
                $shunfengApi->createOutBoundOrder($data);
            }

        //易境通系统发货
        if ($data['warehouse_id'] == 3){
            $YiJTApi = new YiJTApiService();
            $YiJTApi->createOrder($data);
        }


        return  true;
    }
}
